<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="6" :xs="24">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>个人信息</span>
          </div>
          <div>
            <div class="text-center">
              <userAvatar />
            </div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                用户名称
                <div class="pull-right">{{ user.username }}</div>
              </li>
              <li class="list-group-item">
                手机号码
                <div class="pull-right">{{ user.phone }}</div>
              </li>
              <li class="list-group-item">
                企业名称
                <div class="pull-right">{{ user.companyName }}</div>
              </li>
              <li class="list-group-item">
                最后登录时间
                <div class="pull-right">{{ parseTime(user.loginDate) }}</div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
      <el-col :span="18" :xs="24">
        <el-card>
          <div slot="header" class="clearfix">
            <span>企业信息</span>
          </div>
          <div>
            <company-info ref="companyInfo" />
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import userAvatar from "./userAvatar"
import userInfo from "./userInfo"
import resetPwd from "./resetPwd"
import {getCompanyUser, getUserProfile} from "@/api/system/user"
import CompanyInfo from "@/views/system/user/profile/companyInfo";

export default {
  name: "Profile",
  components: {CompanyInfo, userAvatar, userInfo, resetPwd },
  data() {
    return {
      user: {},
      selectedTab: "companyInfo"
    }
  },
  created() {
    this.getUser()
    // 确保子组件渲染完成
    this.$nextTick(() => {
      this.$refs.companyInfo.getCompany();
    });
  },
  methods: {
    getUser() {
      getCompanyUser().then(response => {
        this.user = response.data
      })
    }
  }
}
</script>
